<html>
	<head>
		<meta charset="utf-8">
		<title>get URL</title>
	</head>
	<body>
		<button>点击获取URL</button>
		<script >
			var btn=document.querySelector('button');
			btn.onclick=function(){
				console.log(location.href);
				location.href='http://www.baidu.com';
			}
		</script>
	</body>
</html>